/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package circuit1;

import java.awt.event.*;
import java.util.ArrayList;

/**
 * Az egerkattintast lekezelo osztaly
 * @author Erik
 */
public class MyMouseListener extends MouseAdapter {

    ArrayList<IView> elements;

    /**
     * Konstruktor
     * @param e 
     */
    public MyMouseListener(ArrayList<IView> e) {
        elements = e;
    }

    /**
     * Az egerkattintast lekezelo metodus
     * @param me 
     */
    public void mouseClicked(MouseEvent me) {
            for (IView ui : elements) {
                int pos = ui.getPos();
                if (10 + (pos % 6) * 160 < me.getX() && 75 + (pos % 6) * 160 > me.getX() && (pos / 6) * 60 < me.getY()
                        && (pos / 6) * 60 + 40 > me.getY()) {
                    ui.act();
                }
            }
        }
    }